package Controllers;

import java.awt.Component;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JButton;
import javax.swing.JFrame;

import Boundry.ISMPanel;
import Boundry.WorkerPanel;
/**
 * 
 * @author G16
 *
 */
public class GUIControllerICMManager implements ActionListener{
	ISMPanel ismPanel;
	private static  GUIControllerICMManager Instance = null;
	
	
	private  GUIControllerICMManager(){
		
	}
	/**
	 * GUi contoroler init
	 */
	public void inizializtion(){
		ismPanel = new ISMPanel();
		GlobalData.guiMangaer.switchScreen(ismPanel);
		GlobalData.mainScreen=ismPanel;
		
		for (Component btn: ismPanel.getMainPanel().getComponents())
		{	
			if (btn instanceof JButton)
				((JButton)btn).addActionListener(this);
		}
	}
	
	/**
	 * getinstance singlton perpose
	 * @return
	 */
	public static GUIControllerICMManager getInstance(){
		if (Instance == null ){
			Instance = new GUIControllerICMManager();
		}
		return Instance;
	}
	
	
	public void initTask(){
		
		//initTaskPane=new InitTaskPanel();
	//	GlobalData.guiMangaer.switchScreen(initTaskPane);
		//setListenerToInputPanel(initTaskPane);
		
		
	}
	
	
	
	
	@Override
	/*
	 * (non-Javadoc)
	 * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
	 */
	public void actionPerformed(ActionEvent e) {
		// TODO Auto-generated method stub
		if (e.getSource() == ismPanel.getBtnNewInfoSys()) //TODO ************** Shimon - DONE **************
		{
			ICMManagerController.getInstance().addNewInfoSystem();
			System.out.println("IICMManagerController.getInstance().addNewInfoSystem();");
		}
		else if (e.getSource() == ismPanel.getBtnAddNewWorker()) //TODO ************** Guy Done **************
		{
			ICMManagerController.getInstance().addNewWorker();
			System.out.println("IICMManagerController.getInstance().addNewWorker();");
		}
		else if (e.getSource() ==ismPanel.getBtnAssignStaff() ) // TODO  ************** Guy Done ************** 
		{
			ICMManagerController.getInstance().nominateNewComiteeAndInspector();
			System.out.println("ICMManagerController.getInstance().nominateNewComiteeAndInspector();");
		}
		else if (e.getSource() == ismPanel.getBtnResume())// TODO ************** Shimon Done **************
		{
			ICMManagerController.getInstance().resumeRequest();
			System.out.println("ICMManagerController.getInstance().resumeRequest();");
			
		}
		else if (e.getSource() ==ismPanel.getBtnSearchRequest() ) // TODO **************  Guy DOne **************
		{
			UserController.getInstance().searchRequest();	
			System.out.println("UserController.getInstance().searchRequest();");
			
		}
		else if (e.getSource() ==ismPanel.getBtnSubmitRequest() ) // TODO ************** Shimon DONE **************
		{
			UserController.getInstance().SubmitNewRequest();
			System.out.println("UserController.getInstance().SubmitNewRequest();");
			
		}
		else if (e.getSource() ==ismPanel.getBtnViewRequests() ) // TODO ************** Shimon Done **************
		{
			ICMManagerController.getInstance().showAllRequests();
			System.out.println("ICMManagerController.getInstance().showAllRequests();");
		}
		else if (e.getSource() ==ismPanel.getBtnViewStatisticalInformation() ) // TODO Ron
		{
			ICMManagerController.getInstance().statisticalReports();
			System.out.println("ICMManagerController.getInstance().statisticalReports();");
		}
		else if (e.getSource() ==ismPanel.getBtnViewWorkers() ) // TODO ????  TBD (to be define)
		{
			ICMManagerController.getInstance().showAllWorkers();
			System.out.println("ICMManagerController.getInstance().showAllWorkers();");
		}
	}
	public static void main(String[] args){
		JFrame frame =  new JFrame();
		GuiManager guiMangaer = new GuiManager();
		GlobalData.guiMangaer = guiMangaer;
		
		//frame.setVisible(true);
		//frame.setBounds(0, 0, 700, 700);
		GUIControllerICMManager g =GUIControllerICMManager.getInstance();
		g.inizializtion();
		
	}

	
	
}
